package org.dizena.modules.master.bean;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;

@Document(collection = "master_ress")
@NoArgsConstructor
@Data
public class Res implements Serializable, Comparable<Res>
{
    private static final long serialVersionUID = 1L;
    @Id
    private String id;
    private String resName;
    private String resUrl;
    private Integer resSort;

    private Integer resLevel;
    private String resPid;
    private String resIcon;


    public Res(String id, String resName, String resUrl, Integer resSort, Integer resLevel, String resPid, String resIcon)
    {
        super();
        this.id = id;
        this.resName = resName;
        this.resUrl = resUrl;
        this.resSort = resSort;
        this.resLevel = resLevel;
        this.resPid = resPid;
        this.resIcon = resIcon;
    }

    @Override
    public int compareTo(Res o)
    {
        if (this.getResLevel() < o.getResLevel())
        {
            return -1;
        }
        else if (this.getResLevel() == o.getResLevel())
        {
            if (this.getResSort() < o.getResSort())
            {
                return -1;
            }
            else if (this.getResSort() == o.getResSort())
            {
                return 0;
            }
            else if (this.getResSort() > o.getResSort())
            {
                return 1;
            }
        }
        else if (this.getResLevel() > o.getResLevel())
        {
            return 1;
        }
        return 0;
    }

}
